package com.awei.study.design.found.singleton;

/**
 * 懒汉式2
 */
public class SingletonL2 {

    private SingletonL2() {}

    private static SingletonL2 instance;

    // 当有实例时也锁
    public synchronized SingletonL2 getInstance() {
        if(instance == null) {
            return new SingletonL2();
        }
        return instance;
    }
}
